<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>示例3</title>
    <script src="jquery.js"></script>
    <script>
        $(function (){
            $("#myform").submit(function (){
                const email = $("#email").val()
                const password = $("#password").val()
                if(email == ""){
                    alert('邮箱不能为空')
                    return false;
                }else if(email.indexOf("@")==-1 || email.indexOf(".")==-1){
                    alert("邮箱格式不对，必须包含@和.")
                    return false;
                }

                if(password == ""){
                    alert("密码不能为空");
                    return false;
                }else if(password.length<8){
                    alert("密码必须大于或等于8个字符");
                    return false;
                }

                return true;
            })
        })

    </script>
</head>
<body>
    <form id="myform" action="success.html">
        <p>
            邮箱 <input id="email"/>
        </p>
        <p>
            密码 <input id="password"/>
        </p>
        <p>
            <button type="submit">登录</button>
            <button type="reset">重置</button>
        </p>
    </form>
</body>
</html>